package com.lucifer.repo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * Created by tangdaoyuan on 2017/1/9.
 */
@Repository
public class PingRepo {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    private final static Logger logger = LoggerFactory.getLogger(PingRepo.class);

    public Long ping() {
        try {
            return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM user", Long.class);
        } catch (DataAccessException e) {
            logger.warn(e.getMessage());
            return 0L;
        }

    }
}
